package ac.github.os.internal.core.condition.impl.location

import ac.github.os.internal.core.condition.Condition
import ac.github.os.internal.core.condition.call
import ac.github.os.internal.core.config.StringConfig
import ac.github.os.internal.core.config.get
import ac.github.os.internal.core.trigger.LocationTrigger
import ac.github.os.internal.session.Session
import taboolib.common.platform.Awake

@Awake
class FootBlockCondition : Condition {

    override fun doScreen(session: Session, config: StringConfig): Boolean {

        return session.call<LocationTrigger> {
            val get = config.get("val", 1.0)!!
            val material = config.get("type", "AIR")
            val block = it.location.add(0.0, 0.0, get).block
            return material == block.type.name
        }

    }

    override val namespace: String
        get() = "location:foot-block"
}